package march.test_3_29;

import java.util.ArrayList;

public class main {
    public static void main(String[] args) {
        String str = "\"Letendre\",\"Bruce,Joe,Quan\",William";
        ArrayList<String> arrayList = cotains(str);
        for (int i = 0; i < arrayList.size(); i++) {
            System.out.println(arrayList.get(i));
        }

    }
    public static ArrayList<String> cotains(String str) {
        ArrayList<String> arrayList = new ArrayList<>();
        for (int i = 0; i < str.length(); i++) {
            if(str.charAt(i) == '"') {
                int cur = i + 1;
                while (cur < str.length()&&str.charAt(cur) != '"') {
                    cur++;
                }
                String tmp = str.substring(i + 1,cur);
                arrayList.add(tmp);
                i = cur+1;
            } else {
                int cur = i;
                while (cur < str.length() && str.charAt(cur) != ',') {
                    cur++;
                }
                String tmp = str.substring(i,cur);
                arrayList.add(tmp);
                i = cur;
            }

        }
        return arrayList;
    }
}
